
<?php 

//读取本地配置信息
$myfile = fopen("./POST.ini", "r") or die("Unable to open file!");
$url=fread($myfile,filesize("./POST.ini"));
fclose($myfile);
$myfile = fopen("./BDUSS.ini", "r") or die("Unable to open file!");
$data=fread($myfile,filesize("./BDUSS.ini"));
fclose($myfile);

//获取本机IP
$ip = file_get_contents('http://members.3322.org/dyndns/getip');
$ip="当前的IP是：".$ip." ";
echo $ip;

//php  post方法，支持 http，https协议
function post_data_test($url,$data){
        //初始化一个CURL会话
        $curl = curl_init(); 
        //访问的地址
       curl_setopt($curl, CURLOPT_URL, $url); 
        //认证证书来源的检查
       curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); 
         
        //证书中检查SSL加密算法是否存在
       /* curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);*/
         
        //模拟浏览器
        curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); 
 
        //发送Post请求
        curl_setopt($curl, CURLOPT_POST, 1); 
         
        //Post方式，发送数据包
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data); 
         
        //设置超时
        curl_setopt($curl, CURLOPT_TIMEOUT, 30); 
         
        //返回Header内容
        curl_setopt($curl, CURLOPT_HEADER, 0); 
         
        //文件流的形式返回
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
         
        //执行操作
        $result = curl_exec($curl); 
        if (curl_errno($curl)) {
            echo '错误信息;'.curl_error($curl);
        }
         
        //关闭CURL
        curl_close($curl); 
         
        //返回数据
        return $result; 
    }
     
  

$response=post_data_test($url,$data);


//Unicode解码
function replace_unicode_escape_sequence($match) {
  return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
}
$name = $response;
$response = preg_replace_callback('/\\\\u([0-9a-f]{4})/i', 'replace_unicode_escape_sequence', $name);



echo $response;


//发邮件
//引入发送邮件类

require("./smtp.php"); 

//使用163邮箱服务器

$smtpserver = "smtp.sina.com";

//163邮箱服务器端口 

$smtpserverport = 25;

//你的163服务器邮箱账号

$smtpusermail = "totalcheck@sina.com";

//收件人邮箱

$smtpemailto = "451292130@qq.com";

//你的邮箱账号(去掉@163.com)

$smtpuser = "totalcheck@sina.com";//SMTP服务器的用户帐号 

//你的邮箱密码

$smtppass = "gq19940507"; //SMTP服务器的用户密码 

//邮件主题 

$mailsubject = "百度地图签到结果_PHP";

//邮件内容 

$head=<<<head
<html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "R/xhtml1/DTD/xhtml1-transitional.dtd">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
head;
$end=<<<end
</html>
end;
$mailbody =$ip."<br />".$head.$response.$end;

//邮件格式（HTML/TXT）,TXT为文本邮件 

$mailtype = "HTML";

//这里面的一个true是表示使用身份验证,否则不使用身份验证. 

$smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);

//是否显示发送的调试信息 

$smtp->debug = TRUE;

//发送邮件

$smtp->sendmail($smtpemailto, $smtpusermail, $mailsubject, $mailbody, $mailtype); 
?>

